﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Lidgren.Network;

namespace CodeGame.Networking.Clientside
{
    class ClientProtocolEntity
    {
        public static void CreateEntity(string id)
        {
            NetOutgoingMessage msg = Singletons.Network.CreateMessage(ClientServerNet.EntityCreateRequest);

            msg.Write(id);

            Singletons.Network.SendMessage(msg);
        }

        public static void SpawnEntity(string id, int x, int y)
        {
            NetOutgoingMessage msg = Singletons.Network.CreateMessage(ClientServerNet.EntitiespawnRequest);

            msg.Write(id);
            msg.Write(x);
            msg.Write(y);

            Singletons.Network.SendMessage(msg);
        }

        public static void MoveEntity(string id, int amount)
        {
            NetOutgoingMessage msg = Singletons.Network.CreateMessage(ClientServerNet.EntityMoveRequest);

            msg.Write(id);
            msg.Write(amount);

            Singletons.Network.SendMessage(msg);
        }

        public static void TurnEntity(string id)
        {
            NetOutgoingMessage msg = Singletons.Network.CreateMessage(ClientServerNet.EntityTurnRequest);

            msg.Write(id);

            Singletons.Network.SendMessage(msg);
        }

        public static void TextureEntity(string id, string texture)
        {
            NetOutgoingMessage msg = Singletons.Network.CreateMessage(ClientServerNet.EntityTextureRequest);

            msg.Write(id);
            msg.Write(texture);

            Singletons.Network.SendMessage(msg);
        }

        public static void TintEntity(string id, int r, int g, int b)
        {
            NetOutgoingMessage msg = Singletons.Network.CreateMessage(ClientServerNet.EntityTintRequest);

            msg.Write(id);
            msg.Write(r);
            msg.Write(g);
            msg.Write(b);

            Singletons.Network.SendMessage(msg);
        }

        public static void Pulse(string id)
        {
            NetOutgoingMessage msg = Singletons.Network.CreateMessage(ClientServerNet.WorldPulseRequest);

            msg.Write(id);

            Singletons.Network.SendMessage(msg);
        }

        public static void MakeOwner(string id)
        {
            NetOutgoingMessage msg = Singletons.Network.CreateMessage(ClientServerNet.EntityOwnerRequest);

            msg.Write(id);

            Singletons.Network.SendMessage(msg);
        }

    }
}
